export class cmd_base {
    run() {

    }
    /**
     * 获取字段类型
     * @param type 配置表类型
     * @param key map类型的key
     * @param value map类型的value
     */
    getFieldType(type: string) {
        let temp = type.match(/[a-zA-Z]+/)[0];
        let reg = new RegExp(temp);
        switch (temp) {
            case "int":
            case "float":
            case "byte":
            case "short":
            case "double":
            case "long": {
                type = type.replace(reg, "number");
            } break;
            case "bool": {
                type = type.replace(reg, "boolean");
            } break;
            case "longstr":
            case "locstring": {
                type = type.replace(reg, "string");
            } break;
        }
        return type;
    }
    /**
     * 获取字段readonly类型
     * @param type 普通类型
     */
    getReadonlyType(type: string) {
        //如果是数组
        if (type.match(/\[\]/)) {
            let tempType = type.match(/[a-zA-Z]+/)[0];
            let length = type.split("[]").length - 1;
            for (let index = 0; index < length; index++) {
                tempType = `Readonly<${tempType}[]>`
            }
            type = tempType;
        }
        return type;
    }
}